import Vue from 'vue';
import App from './App';
import router from './router';

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'
import "babel-polyfill";


import Vuex from 'vuex'
Vue.use(Vuex)
import store from './vuex/store'
Vue.prototype.$store = store 
 

Vue.use(ElementUI);

// import mavonEditor from 'mavon-editor'
// import 'mavon-editor/dist/css/index.css'
// Vue.use(mavonEditor);

// import Icon from 'vue-awesome/components/Icon'
// import 'vue-awesome/icons/'

// Vue.component('icon', Icon)
 
import { Cookie } from './js/common';
	
router.beforeEach((to, from, next) => {

var user = Cookie.Get('token');
 if (to.meta.title)
 {
 	document.title =to.meta.title;
 }
 
//if(process.env.NODE_ENV =='development'){
//	Cookie.Set('token', '8ba5cba4db64d4b17cd7bca3dcb74027');
//	Cookie.Set('uname', '谌舜谋');
//	Cookie.Set("company_key",1);
//	user = '056632360935522171'; 
//}


if (!user && to.path.substr(0,5).toLowerCase() != '/auth' && to.path.toLowerCase() != '/login') {
    next({ path: '/login' })
} else {
	next();
}
})
//alert("to"+to.path)
//alert('from'+from.path)
//if( user || to.path === '/login' || to.path === '/authPC'){
//	alert("user")
//	next();
//}else{
//	alert("auth")
//	next({path:'/authPC',query:{props:to}})
//}
//})



new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app');